package com.da.javatest.leetCode;

import java.util.Arrays;

/**
 * @author chenlida
 * @date 2019/3/1 14:31
 * @description
 */
public class Code645 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Code645().findErrorNums(new int[] {1, 1})));
    }

    public int[] findErrorNums(int[] nums) {
        int[] r = new int[2];
        Arrays.sort(nums);
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] - nums[i - 1] == 0) {
                r[0] = nums[i];
            }
            if (nums[i] - nums[i - 1] == 2) {
                r[1] = nums[i] - 1;
            }
        }
        if (r[1] == 0) {
            r[1] = nums[0] != 1 ? 1 : nums.length;
        }
        return r;
    }
}
